﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ShenBaoNew.aspx.cs" Inherits="Wsbs_ShenBao" %>

<%@ Register Src="~/UserControls/WebNewHead.ascx" TagPrefix="uc1" TagName="WebNewHead" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>在线申报</title>
    <script type="text/javascript" src="../ScriptFile/jquery.js"></script>
    <script type="text/javascript" src="../ScriptFile/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../ScriptFile/Common/Jquery.Global.js"></script>
    <script type="text/javascript" src="../ScriptFile/Common/Jquery.Common.js"></script>
    <script type="text/javascript" src="../ScriptFile/cookie.js"></script>
    <link href="../App_Themes/SkinFile/CSS/login_index.css" rel="stylesheet" />
</head>
<body style="background-color: #f7f7f7;">
    <script type="text/javascript">
        var isSaveSuccess = false;
        //判断表单是否更改
        var isChange = false;
        var currentUrl, currentCtrlId;
        var strFlowType = encodeURI('<%=Request["flowtype"]%>');
        var strFlowName = encodeURI('<%=Request["flowname"]%>');
        var userid = encodeURI('<%=Session["UserID"]%>');
        var username = encodeURI('<%=ViewState["UserName"]%>');

        function GetIID() {
            return $("#<%=hidIId.ClientID %>").val(); //获取client的值
        }

        //消息提示框
        function ConfirmMsg(strInfo) {
            return confirm(strInfo);
        }

        //表单保存后的回调方法
        function SaveIId() {
            var strBgFlag = $("#<%=hidBgFlag.ClientID %>").val(); //查看是否具备变更权限
            var strYqFlag = $("#<%=hidYqFlag.ClientID %>").val(); //查看是否具备延期权限
            if (strBgFlag == "3" || strYqFlag == "3") {//如果是变更或延期状态则不需要设置状态位，直接跳出
                return;
            }

            //添加提醒消息
            $.ajax({
                url: 'AjaxSaveForm.ashx',
                data: "dataIId=" + GetIID() + "&dataFlowname=" + strFlowName + "&flowType=" + strFlowType + "&userId=" + userid + "&userName=" + username,
                type: 'GET',
                dataType: 'text',
                cache: false,
                async: false,
                error: function () {
                    alert('保存出现异常');
                },
                success: function (data) {
                    if (data == "保存失败") {
                        alert(data);
                    }
                    else {
                        isSaveSuccess = true;
                        if (currentCtrlId != "" && typeof (currentCtrlId) != "undefined" && currentUrl != "") {
                            $("#frmChild").attr("src", currentUrl);
                            $("#tabMenu td[id ^= 'td']").attr("class", "tabcontrol_button03");
                            $("#" + currentCtrlId).attr("class", "tabcontrol_button05");
                            currentCtrlId = "";
                            currentUrl = "";
                        }
                        isChange = false;
                        alert("保存成功");
                    }
                }
            });
        }
        //页面加载时执行
        $(document).ready(function () {
            $("#tt").tabs('select', 0);
            //设置打印按钮的可操作性
            var printFlag = $("#<%=hidPrintFlag.ClientID%>").val();
            if (printFlag == "2" || printFlag == "3" || printFlag == "-4") {
                $("#printform").show();
                $("#printformView").show();
            }
            loadDatatabClick();
            transSrc();
        });

        //加载tab的select事件并执行title和src传值公共变量
        function loadDatatabClick() {
            $('#tt').tabs({
                onSelect: function (title) {
                    if (strIfrmetitle != '上传材料') {
                        //如果保存按钮灰掉就不要保存
                        if ($("input:disabled").attr("id") == "saveform")
                        {
                            isChange = false;
                        }

                        if (isChange) {
                            strIframeSrc.SaveAll(false, SaveIId);
                        }
                    }
                    strIfrmetitle = title;
                    transSrc();

                    if (title == "申请表") {
                        refreshIframe();
                    }
                }
            });
        }

        var strIframeSrc = null;//保存用
        var strIfrmetitle = null;//tab标题
        var iframeFid = null;//保存iframeid
        //获取当前选中的tab的src并复制到公共变量内
        function transSrc() {
            var tbIframe = GetSelectedFrameId();
            var iframe = window.frames[tbIframe];
            strIframeSrc = iframe;
            iframeFid = $("#" + tbIframe).attr("title");
            SetButtonDisplay(strIfrmetitle);

        }

        //设置按钮
        function SetButtonDisplay(strTabName) {
            if (isChange) //数据已修改
            {
                var varEnableSave = $("#saveform").attr("disabled");
                //判断按钮是否可用
                if (varEnableSave == false || typeof (varEnableSave) == "undefined") {
                    isSaveSuccess = false;
                }
                else {
                    isSaveSuccess = true;
                    isChange = false;
                }
            }
            else {
                isSaveSuccess = true;
            }
            //排除上传附件
            if (strTabName == "-1") {
                $("#saveform").hide();
            }
            else {
                $("#saveform").show();

            }//判断是否是材料上传--结束
            //end
        }

        //保存iframe表单
        function SaveInfo() {
            var tbIframe = GetSelectedFrameId();
            var iframe = window.frames[tbIframe];

            //新保存方法,采用HtmlMainPage.aspx的方法
            if (isChange) {
                try {
                    iframe.SaveAll(false, SaveIId);
                }
                catch (ex) {
                    iframe.contentWindow.SaveAll(false, SaveIId);
                }
            }
            else {
                alert("未经过任何改动，无需保存");
            }
        }

        //提交
        function SubmitInfo() {
            if (!ConfirmMsg("确定您填写的申请信息和上报材料符合要求并提交吗？")) {
                return;
            }

            if ($("#saveform").css("display") != "none") {
                if (isChange) {
                    //SaveInfo();
                    alert("数据已更改，请先保存");
                    return;
                }
            }

            var strBgFlag = $("#<%=hidBgFlag.ClientID %>").val(); //查看是否具备变更权限
            var strYqFlag = $("#<%=hidYqFlag.ClientID %>").val(); //查看是否具备延期权限

            //设置提交状态位
            $.ajax({
                url: 'AjaxSubmitFlag.ashx',
                data: "dataIId=" + GetIID() + "&dataFlowname=" + strFlowName + "&flowtype=" + strFlowType + "&bgflag=" + strBgFlag + "&yqflag=" + strYqFlag + "&userId=" + userid + "&userName=" + username,
                type: 'GET',
                dataType: 'text',
                cache: false,
                async: false,
                error: function () {
                    alert('提交未成功，请检查是否未上传材料或是否未保存表单');
                },
                success: function (data) {
                    if (data == "提交成功") {
                        alert('提交成功');
                        $("#saveform").attr("disabled", true);
                        $("#submitform").attr("disabled", true);
                        //$("#btnAddCopy").attr("disabled", true);
                    }
                    else
                        alert('请检查是否未上传材料或是否未保存表单');
                }
            });
        }



        //打开向导模式
        function openWizardUrl() {
            window.location.href = "ShenBaoWithWizard.aspx?IId=" + GetIID() + "&flowname=" + strFlowName + "&flowtype=" + strFlowType;
        }

        //拷贝并添加
        function CopyAndAdd() {
            var strIID = GetIID();
            //拷贝当前数据并新建
            $.ajax({
                url: 'AjaxCopyAndAdd.ashx',
                data: "flowname=" + strFlowName + "&flowtype=" + strFlowType + "&iid=" + strIID + "&fid=" + iframeFid,
                type: 'POST',
                dataType: 'text',
                async: false,
                success: function (newUrl) {
                    if (newUrl != "") {
                        window.location.href = newUrl;
                    }
                    if ($('#tt').tabs('exists', strIfrmetitle)) {
                        $("tt").tabs('select', strIfrmetitle);
                    }
                }
            });
        }

        //打开提示框
        //function OpenConfirm() {
        //    $('#divConfirm').window('open');
        //}

        ////保存消息提示框的cookie
        //function SaveCookie() {
        //    var ckvalue = "0";
        //    if ($("#cbxNotes").is(":checked")) {
        //        ckvalue = "1";
        //    }
        //    else {
        //        ckvalue = "0";
        //    }
        //    setCookie('XDcookie', ckvalue);
        //    $('#divConfirm').window('close');
        //}

        function GetSelectedFrameId()
        {
            var pp = $("#tt").tabs('getSelected');
            var tabId = pp.attr("id");
            var tbIframe = $("#" + tabId + " iframe:first-child").attr("id");
            return tbIframe;
        }

        //打印
        function framePrint() {
            var tbIframe = GetSelectedFrameId();
            if ($("#" + tbIframe).attr("src") != "") {
                window.open($("#" + tbIframe).attr("src") + "&act=Print", "printfrm", "width=1,height=1");
            }
        }
        //打印预览
        function framePrintPreview() {
            var tbIframe = GetSelectedFrameId();
            if ($("#" + tbIframe).attr("src") != "") {
                window.open($("#" + tbIframe).attr("src") + "&act=PrintView", "printfrm");
            }
        }

        ///刷新iframe;
        function refreshIframe() {
            var tbIframe = GetSelectedFrameId();
            var strTemp = $("#" + tbIframe).attr("src");
            if (strTemp.indexOf('rdm=') > 0) {
                strTemp = strTemp.substr(0, strTemp.indexOf('rdm='));
                strTemp += 'rdm=' + Math.random() * 100;
            }
            else {
                strTemp += '&rdm=' + Math.random() * 100;
            }

            $("#" + tbIframe).attr("src",strTemp);

        }

    </script>
    <form runat="server">

        <uc1:WebNewHead runat="server" ID="WebNewHead" />
        <div style="width: 1000px; margin: 0 auto; padding-left: 40px; margin-top: 17px;">
            <div style="padding-top: 3px; height: 25px; border: 1px solid #eaeaea; width: 100%; text-align: right; border-top: 2px solid #46D078"><%=GetSubmit()%> </div>
            <div id="tt" class="easyui-tabs" style="width: 1000px; height: 1200px; float: left; margin-top: 5px; text-align: center">
                <%=GetContent() %>
            </div>

        </div>

       <%-- <div id="divConfirm" class="easyui-window" title="国家测绘地理信息局行政许可网上办理大厅" data-options="modal:true,closed:true,iconCls:'icon-save',minimizable:false,maximizable
:false,collapsible:false"
            style="width: 400px; height: 150px; padding: 10px;">
            在线申报有普通模式和向导模式两种方式，向导模式可以引导您进行在线申报，进入向导模式<a href="#" onclick="openWizardUrl();">点击这里</a>。
       
                <table style="width: 100%;">
                    <tr>
                        <td>
                            <input id="cbxNotes" type="checkbox" />下次不再提示
                        </td>
                        <td style="text-align: right">
                            <input id="btnOK" class="button" onclick="SaveCookie()" value="确定" type="button" /><input
                                id="btnClose" class="button" value="关闭" type="button" onclick="$('#divConfirm').window('close')" />
                        </td>
                    </tr>
                </table>
        </div>--%>

        <input type="hidden" value="" id="hidIId" runat="server" />
        <input type="hidden" value="" id="hidBgFlag" runat="server" />
        <input type="hidden" value="" id="hidYqFlag" runat="server" />
        <input type="hidden" value="" id="hidPrintFlag" runat="server" />

    </form>
</body>
</html>

